package cn.mes.service;

import cn.mes.entity.FormData;
import cn.mes.mapper.MesMapper;
import cn.mes.service.impl.IMesService;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MesSericeImpl implements IMesService {

    @Autowired
    private MesMapper mesMapper;

    @Override
    public List<Map<String, Object>> mesList() {
        List<Map<String, Object>> maps = mesMapper.mesList();
        for (Map<String, Object> map : maps) {
            String message = (String) map.get("message");
            String mes = StringEscapeUtils.escapeHtml3(message);
            map.put("message", mes);
        }
        return maps;
    }

    @Override
    public int submitForm(FormData formData) {
        return mesMapper.submitForm(formData);
    }

    @Override
    public int updateMessage(FormData formData) {
        return mesMapper.updateById(formData);
    }

    @Override
    public void deleteMessage(String id) {
        mesMapper.deleteById(id);
    }
}
